%%%%%%%%%%%%%%%%%%%% FIGURE 1, 2 & 3 %%%%%%%%%%%%%%%%%%%%%%%%%%%%
clc
clear
close all

% %%%%%%%%%%%%%%%%%%%%% FIGURE 1a %%%%%%%%%%%%%%%%%%%%%%%%%%%%
load RTDB_FIG1

lo=find(isfinite(GDP(:,1)),1,'last');
la=find(isfinite(GDP(:,end)),1,'last');
T=size(GDP,1);
last_obs=nan(T,1);
for i=lo:la
    sl=find(isfinite(GDP(i,:)));
    last_obs(i,:)=GDP(i,sl(1));
end

figure(1)
plot(dates_gdp,GDP,dates_gdp,last_obs,'x-r','LineWidth',2,'MarkerSize',15),...
    datetick('x',12),xlabel('time'),axis([dates_gdp(1) dates_gdp(T) -6 6]),title('EA Real GDP')

%%%%%%%%%%%%%%%%%%%%% FIGURE 1b %%%%%%%%%%%%%%%%%%%%%%%%%%%%
lo=find(isfinite(HICP(:,1)),1,'last');
la=find(isfinite(HICP(:,end)),1,'last');
T=size(HICP,1);
last_obs=nan(T,1);
for i=lo:la
    sl=find(isfinite(HICP(i,:)));
    last_obs(i,:)=HICP(i,sl(1));
end

figure(2)
plot(dates_mon,HICP,dates_mon,last_obs,'x-r','LineWidth',2,'MarkerSize',15),...
    datetick('x',12),xlabel('time'),axis([dates_mon(1) dates_mon(T) 0 6]),title('EA HICP')
%%%%%%%%%%%%%%%%%%%%% FIGURE 1c %%%%%%%%%%%%%%%%%%%%%%%%%%%%
lo=find(isfinite(IP(:,1)),1,'last');
la=find(isfinite(IP(:,end)),1,'last');
T=size(IP,1);
last_obs=nan(T,1);
for i=lo:la
    sl=find(isfinite(IP(i,:)));
    last_obs(i,:)=IP(i,sl(1));
end

figure(3)
plot(dates_mon,IP,dates_mon,last_obs,'x-r','LineWidth',2,'MarkerSize',15),...
    datetick('x',12),xlabel('time'),axis([dates_mon(1) dates_mon(T) -20 10]),title('EA IP')
%%%%%%%%%%%%%%%%%%%%% FIGURE 1d %%%%%%%%%%%%%%%%%%%%%%%%%%%%
lo=find(isfinite(UR(:,1)),1,'last');
la=find(isfinite(UR(:,end)),1,'last');
T=size(UR,1);
last_obs=nan(T,1);
for i=lo:la
    sl=find(isfinite(UR(i,:)));
    last_obs(i,:)=UR(i,sl(1));
end

figure(4)
plot(dates_mon,UR,dates_mon,last_obs,'x-r','LineWidth',2,'MarkerSize',15),...
    datetick('x',12),xlabel('time'),axis([dates_mon(1) dates_mon(T) 6 12]),title('EA UR')

%%%%%%%%%%%%%%%%%%%%%% FIGURE 2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

load RTDB_GDP_qoq 
dates_gdp=datevec(dates_gdp);
Q4_01=find(dates_gdp(:,1)==2001 & dates_gdp(:,2)==12);
nv=size(vintages,1);
figure(5)
plot(vintages,GDP_qoq(Q4_01,:),'o-r',vintages,zeros(nv,1),'LineWidth',2),...
    datetick('x',12),xlabel('vintages'),axis([vintages(1) vintages(end) -.3 .2]),title('Real GDP Q401 q-o-q')

%%%%%%%%%%%%%%%%%%%%% FIGURE 3a %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
load RTDB_TAB2
load RTDB_TAB3

A=GDP;
for j=2:27
    Y1(j-1)=A(j+1,(j-1)*2+j);Y2(j-1)=A(j+1,(j-1)*2+j+1);Y3(j-1)=A(j+1,(j-1)*2+j+2);
    Y4(j-1)=A(j+1,(j-1)*2+j+3);Y5(j-1)=A(j+1,(j-1)*2+j+4);Y6(j-1)=A(j+1,(j-1)*2+j+5);
    Y7(j-1)=A(j+1,(j-1)*2+j+6);Y8(j-1)=A(j+1,(j-1)*2+j+7);Y9(j-1)=A(j+1,(j-1)*2+j+8);Y10(j-1)=A(j+1,(j-1)*2+j+9);
    Y11(j-1)=A(j+1,(j-1)*2+j+10);Y12(j-1)=A(j+1,(j-1)*2+j+11);Y13(j-1)=A(j+1,(j-1)*2+j+12);Y14(j-1)=A(j+1,(j-1)*2+j+13);
    Y15(j-1)=A(j+1,(j-1)*2+j+14);Y16(j-1)=A(j+1,(j-1)*2+j+15);Y17(j-1)=A(j+1,(j-1)*2+j+16);Y18(j-1)=A(j+1,(j-1)*2+j+17);
    Y19(j-1)=A(j+1,(j-1)*2+j+18);Y20(j-1)=A(j+1,(j-1)*2+j+19);Y21(j-1)=A(j+1,(j-1)*2+j+20);Y22(j-1)=A(j+1,(j-1)*2+j+21);
    Y23(j-1)=A(j+1,(j-1)*2+j+22);Y24(j-1)=A(j+1,(j-1)*2+j+23);
end

std_ea_gdp=nanstd([Y1' Y2' Y3' Y4' Y5' Y6' Y7' Y8' Y9' Y10' Y11' Y12' Y13' Y14' Y15' Y16' Y17' Y18' Y19' Y20' Y21' Y22' Y23' Y24']-Y24'*ones(1,24))./nanstd(A(:,end));

A=US_GDP;
for j=2:27
    Y1(j-1)=A(j+1,(j-1)*2+j);Y2(j-1)=A(j+1,(j-1)*2+j+1);Y3(j-1)=A(j+1,(j-1)*2+j+2);
    Y4(j-1)=A(j+1,(j-1)*2+j+3);Y5(j-1)=A(j+1,(j-1)*2+j+4);Y6(j-1)=A(j+1,(j-1)*2+j+5);
    Y7(j-1)=A(j+1,(j-1)*2+j+6);Y8(j-1)=A(j+1,(j-1)*2+j+7);Y9(j-1)=A(j+1,(j-1)*2+j+8);Y10(j-1)=A(j+1,(j-1)*2+j+9);
    Y11(j-1)=A(j+1,(j-1)*2+j+10);Y12(j-1)=A(j+1,(j-1)*2+j+11);Y13(j-1)=A(j+1,(j-1)*2+j+12);Y14(j-1)=A(j+1,(j-1)*2+j+13);
    Y15(j-1)=A(j+1,(j-1)*2+j+14);Y16(j-1)=A(j+1,(j-1)*2+j+15);Y17(j-1)=A(j+1,(j-1)*2+j+16);Y18(j-1)=A(j+1,(j-1)*2+j+17);
    Y19(j-1)=A(j+1,(j-1)*2+j+18);Y20(j-1)=A(j+1,(j-1)*2+j+19);Y21(j-1)=A(j+1,(j-1)*2+j+20);Y22(j-1)=A(j+1,(j-1)*2+j+21);
    Y23(j-1)=A(j+1,(j-1)*2+j+22);Y24(j-1)=A(j+1,(j-1)*2+j+23);
end

std_us_gdp=nanstd([Y1' Y2' Y3' Y4' Y5' Y6' Y7' Y8' Y9' Y10' Y11' Y12' Y13' Y14' Y15' Y16' Y17' Y18' Y19' Y20' Y21' Y22' Y23' Y24']-Y24'*ones(1,24))./nanstd(A(:,end));

A=JP_GDP;
for j=2:27
    Y1(j-1)=A(j+1,(j-1)*2+j);Y2(j-1)=A(j+1,(j-1)*2+j+1);Y3(j-1)=A(j+1,(j-1)*2+j+2);
    Y4(j-1)=A(j+1,(j-1)*2+j+3);Y5(j-1)=A(j+1,(j-1)*2+j+4);Y6(j-1)=A(j+1,(j-1)*2+j+5);
    Y7(j-1)=A(j+1,(j-1)*2+j+6);Y8(j-1)=A(j+1,(j-1)*2+j+7);Y9(j-1)=A(j+1,(j-1)*2+j+8);Y10(j-1)=A(j+1,(j-1)*2+j+9);
    Y11(j-1)=A(j+1,(j-1)*2+j+10);Y12(j-1)=A(j+1,(j-1)*2+j+11);Y13(j-1)=A(j+1,(j-1)*2+j+12);Y14(j-1)=A(j+1,(j-1)*2+j+13);
    Y15(j-1)=A(j+1,(j-1)*2+j+14);Y16(j-1)=A(j+1,(j-1)*2+j+15);Y17(j-1)=A(j+1,(j-1)*2+j+16);Y18(j-1)=A(j+1,(j-1)*2+j+17);
    Y19(j-1)=A(j+1,(j-1)*2+j+18);Y20(j-1)=A(j+1,(j-1)*2+j+19);Y21(j-1)=A(j+1,(j-1)*2+j+20);Y22(j-1)=A(j+1,(j-1)*2+j+21);
    Y23(j-1)=A(j+1,(j-1)*2+j+22);Y24(j-1)=A(j+1,(j-1)*2+j+23);
end

std_jp_gdp=nanstd([Y1' Y2' Y3' Y4' Y5' Y6' Y7' Y8' Y9' Y10' Y11' Y12' Y13' Y14' Y15' Y16' Y17' Y18' Y19' Y20' Y21' Y22' Y23' Y24']-Y24'*ones(1,24))./nanstd(A(:,end));

figure(6)
plot(1:24,std_ea_gdp,'b-d',1:24,std_us_gdp,'r-s',1:24,std_jp_gdp,'g-^'),title('Revisions for real GDP'),...
    xlabel('months after reference period'), ylabel('standard deviation of the revisions'),legend('EA','US','JP')
%%%%%%%%%%%%%%%%%%%%% FIGURE 3b %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
A=HICP;nn=size(A,2);

for j=2:nn-23
    Y1(j-1)=A(j+1,j);Y2(j-1)=A(j+1,j+1);Y3(j-1)=A(j+1,j+2);Y4(j-1)=A(j+1,j+3);Y5(j-1)=A(j+1,j+4);
    Y6(j-1)=A(j+1,j+5);Y7(j-1)=A(j+1,j+6);Y8(j-1)=A(j+1,j+7);Y9(j-1)=A(j+1,j+8);Y10(j-1)=A(j+1,j+9);
    Y11(j-1)=A(j+1,j+10);Y12(j-1)=A(j+1,j+11);Y13(j-1)=A(j+1,j+12);Y14(j-1)=A(j+1,j+13);Y15(j-1)=A(j+1,j+14);
    Y16(j-1)=A(j+1,j+15);Y17(j-1)=A(j+1,j+16);Y18(j-1)=A(j+1,j+17);Y19(j-1)=A(j+1,j+18);Y20(j-1)=A(j+1,j+19);
    Y21(j-1)=A(j+1,j+20);Y22(j-1)=A(j+1,j+21);Y23(j-1)=A(j+1,j+22);Y24(j-1)=A(j+1,j+23);
end

std_ea_hicp=nanstd([Y1' Y2' Y3' Y4' Y5' Y6' Y7' Y8' Y9' Y10' Y11' Y12' Y13' Y14' Y15' Y16' Y17' Y18' Y19' Y20' Y21' Y22' Y23' Y24']-Y24'*ones(1,24))./nanstd(A(:,end));
std_ea_hicp(1)=NaN;
A=US_CPI;nn=size(A,2);

for j=2:nn-23
    Y1(j-1)=A(j+1,j);Y2(j-1)=A(j+1,j+1);Y3(j-1)=A(j+1,j+2);Y4(j-1)=A(j+1,j+3);Y5(j-1)=A(j+1,j+4);
    Y6(j-1)=A(j+1,j+5);Y7(j-1)=A(j+1,j+6);Y8(j-1)=A(j+1,j+7);Y9(j-1)=A(j+1,j+8);Y10(j-1)=A(j+1,j+9);
    Y11(j-1)=A(j+1,j+10);Y12(j-1)=A(j+1,j+11);Y13(j-1)=A(j+1,j+12);Y14(j-1)=A(j+1,j+13);Y15(j-1)=A(j+1,j+14);
    Y16(j-1)=A(j+1,j+15);Y17(j-1)=A(j+1,j+16);Y18(j-1)=A(j+1,j+17);Y19(j-1)=A(j+1,j+18);Y20(j-1)=A(j+1,j+19);
    Y21(j-1)=A(j+1,j+20);Y22(j-1)=A(j+1,j+21);Y23(j-1)=A(j+1,j+22);Y24(j-1)=A(j+1,j+23);
end

std_us_cpi=nanstd([Y1' Y2' Y3' Y4' Y5' Y6' Y7' Y8' Y9' Y10' Y11' Y12' Y13' Y14' Y15' Y16' Y17' Y18' Y19' Y20' Y21' Y22' Y23' Y24']-Y24'*ones(1,24))./nanstd(A(:,end));
std_us_cpi(1)=NaN;

A=JP_CPI;nn=size(A,2);

for j=2:nn-23
    Y1(j-1)=A(j+1,j);Y2(j-1)=A(j+1,j+1);Y3(j-1)=A(j+1,j+2);Y4(j-1)=A(j+1,j+3);Y5(j-1)=A(j+1,j+4);
    Y6(j-1)=A(j+1,j+5);Y7(j-1)=A(j+1,j+6);Y8(j-1)=A(j+1,j+7);Y9(j-1)=A(j+1,j+8);Y10(j-1)=A(j+1,j+9);
    Y11(j-1)=A(j+1,j+10);Y12(j-1)=A(j+1,j+11);Y13(j-1)=A(j+1,j+12);Y14(j-1)=A(j+1,j+13);Y15(j-1)=A(j+1,j+14);
    Y16(j-1)=A(j+1,j+15);Y17(j-1)=A(j+1,j+16);Y18(j-1)=A(j+1,j+17);Y19(j-1)=A(j+1,j+18);Y20(j-1)=A(j+1,j+19);
    Y21(j-1)=A(j+1,j+20);Y22(j-1)=A(j+1,j+21);Y23(j-1)=A(j+1,j+22);Y24(j-1)=A(j+1,j+23);
end

std_jp_cpi=nanstd([Y1' Y2' Y3' Y4' Y5' Y6' Y7' Y8' Y9' Y10' Y11' Y12' Y13' Y14' Y15' Y16' Y17' Y18' Y19' Y20' Y21' Y22' Y23' Y24']-Y24'*ones(1,24))./nanstd(A(:,end));
std_jp_cpi(1)=NaN;

figure(7)
plot(1:24,std_ea_hicp,'b-d',1:24,std_us_cpi,'r-s',1:24,std_jp_cpi,'g-^'),title('Revisions for HICP/CPI'),...
    xlabel('months after reference period'), ylabel('standard deviation of the revisions'),legend('EA','US','JP')


%%%%%%%%%%%%%%%%%%%%% FIGURE 3c %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

A=IP;nn=size(A,2);

for j=2:nn-23
    Y1(j-1)=A(j+1,j);Y2(j-1)=A(j+1,j+1);Y3(j-1)=A(j+1,j+2);Y4(j-1)=A(j+1,j+3);Y5(j-1)=A(j+1,j+4);
    Y6(j-1)=A(j+1,j+5);Y7(j-1)=A(j+1,j+6);Y8(j-1)=A(j+1,j+7);Y9(j-1)=A(j+1,j+8);Y10(j-1)=A(j+1,j+9);
    Y11(j-1)=A(j+1,j+10);Y12(j-1)=A(j+1,j+11);Y13(j-1)=A(j+1,j+12);Y14(j-1)=A(j+1,j+13);Y15(j-1)=A(j+1,j+14);
    Y16(j-1)=A(j+1,j+15);Y17(j-1)=A(j+1,j+16);Y18(j-1)=A(j+1,j+17);Y19(j-1)=A(j+1,j+18);Y20(j-1)=A(j+1,j+19);
    Y21(j-1)=A(j+1,j+20);Y22(j-1)=A(j+1,j+21);Y23(j-1)=A(j+1,j+22);Y24(j-1)=A(j+1,j+23);
end

std_ea_ip=nanstd([Y1' Y2' Y3' Y4' Y5' Y6' Y7' Y8' Y9' Y10' Y11' Y12' Y13' Y14' Y15' Y16' Y17' Y18' Y19' Y20' Y21' Y22' Y23' Y24']-Y24'*ones(1,24))./nanstd(A(:,end));
std_ea_ip(1:2)=NaN;
A=US_IP;nn=size(A,2);

for j=2:nn-23
    Y1(j-1)=A(j+1,j);Y2(j-1)=A(j+1,j+1);Y3(j-1)=A(j+1,j+2);Y4(j-1)=A(j+1,j+3);Y5(j-1)=A(j+1,j+4);
    Y6(j-1)=A(j+1,j+5);Y7(j-1)=A(j+1,j+6);Y8(j-1)=A(j+1,j+7);Y9(j-1)=A(j+1,j+8);Y10(j-1)=A(j+1,j+9);
    Y11(j-1)=A(j+1,j+10);Y12(j-1)=A(j+1,j+11);Y13(j-1)=A(j+1,j+12);Y14(j-1)=A(j+1,j+13);Y15(j-1)=A(j+1,j+14);
    Y16(j-1)=A(j+1,j+15);Y17(j-1)=A(j+1,j+16);Y18(j-1)=A(j+1,j+17);Y19(j-1)=A(j+1,j+18);Y20(j-1)=A(j+1,j+19);
    Y21(j-1)=A(j+1,j+20);Y22(j-1)=A(j+1,j+21);Y23(j-1)=A(j+1,j+22);Y24(j-1)=A(j+1,j+23);
end

std_us_ip=nanstd([Y1' Y2' Y3' Y4' Y5' Y6' Y7' Y8' Y9' Y10' Y11' Y12' Y13' Y14' Y15' Y16' Y17' Y18' Y19' Y20' Y21' Y22' Y23' Y24']-Y24'*ones(1,24))./nanstd(A(:,end));
std_us_ip(1)=NaN;

A=JP_IP;nn=size(A,2);

for j=2:nn-23
    Y1(j-1)=A(j+1,j);Y2(j-1)=A(j+1,j+1);Y3(j-1)=A(j+1,j+2);Y4(j-1)=A(j+1,j+3);Y5(j-1)=A(j+1,j+4);
    Y6(j-1)=A(j+1,j+5);Y7(j-1)=A(j+1,j+6);Y8(j-1)=A(j+1,j+7);Y9(j-1)=A(j+1,j+8);Y10(j-1)=A(j+1,j+9);
    Y11(j-1)=A(j+1,j+10);Y12(j-1)=A(j+1,j+11);Y13(j-1)=A(j+1,j+12);Y14(j-1)=A(j+1,j+13);Y15(j-1)=A(j+1,j+14);
    Y16(j-1)=A(j+1,j+15);Y17(j-1)=A(j+1,j+16);Y18(j-1)=A(j+1,j+17);Y19(j-1)=A(j+1,j+18);Y20(j-1)=A(j+1,j+19);
    Y21(j-1)=A(j+1,j+20);Y22(j-1)=A(j+1,j+21);Y23(j-1)=A(j+1,j+22);Y24(j-1)=A(j+1,j+23);
end

std_jp_ip=nanstd([Y1' Y2' Y3' Y4' Y5' Y6' Y7' Y8' Y9' Y10' Y11' Y12' Y13' Y14' Y15' Y16' Y17' Y18' Y19' Y20' Y21' Y22' Y23' Y24']-Y24'*ones(1,24))./nanstd(A(:,end));
std_jp_ip(1)=NaN;

figure(8)
plot(1:24,std_ea_ip,'b-d',1:24,std_us_ip,'r-s',1:24,std_jp_ip,'g-^'),title('Revisions for IP'),...
    xlabel('months after reference period'), ylabel('standard deviation of the revisions'),legend('EA','US','JP')

%%%%%%%%%%%%%%%%%%%%% FIGURE 3d %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

A=UR;nn=size(A,2);

for j=2:nn-23
    Y1(j-1)=A(j+1,j);Y2(j-1)=A(j+1,j+1);Y3(j-1)=A(j+1,j+2);Y4(j-1)=A(j+1,j+3);Y5(j-1)=A(j+1,j+4);
    Y6(j-1)=A(j+1,j+5);Y7(j-1)=A(j+1,j+6);Y8(j-1)=A(j+1,j+7);Y9(j-1)=A(j+1,j+8);Y10(j-1)=A(j+1,j+9);
    Y11(j-1)=A(j+1,j+10);Y12(j-1)=A(j+1,j+11);Y13(j-1)=A(j+1,j+12);Y14(j-1)=A(j+1,j+13);Y15(j-1)=A(j+1,j+14);
    Y16(j-1)=A(j+1,j+15);Y17(j-1)=A(j+1,j+16);Y18(j-1)=A(j+1,j+17);Y19(j-1)=A(j+1,j+18);Y20(j-1)=A(j+1,j+19);
    Y21(j-1)=A(j+1,j+20);Y22(j-1)=A(j+1,j+21);Y23(j-1)=A(j+1,j+22);Y24(j-1)=A(j+1,j+23);
end

std_ea_ur=nanstd([Y1' Y2' Y3' Y4' Y5' Y6' Y7' Y8' Y9' Y10' Y11' Y12' Y13' Y14' Y15' Y16' Y17' Y18' Y19' Y20' Y21' Y22' Y23' Y24']-Y24'*ones(1,24))./nanstd(A(:,end));
std_ea_ur(1)=NaN;

A=US_UR;nn=size(A,2);

for j=2:nn-23
    Y1(j-1)=A(j+1,j);Y2(j-1)=A(j+1,j+1);Y3(j-1)=A(j+1,j+2);Y4(j-1)=A(j+1,j+3);Y5(j-1)=A(j+1,j+4);
    Y6(j-1)=A(j+1,j+5);Y7(j-1)=A(j+1,j+6);Y8(j-1)=A(j+1,j+7);Y9(j-1)=A(j+1,j+8);Y10(j-1)=A(j+1,j+9);
    Y11(j-1)=A(j+1,j+10);Y12(j-1)=A(j+1,j+11);Y13(j-1)=A(j+1,j+12);Y14(j-1)=A(j+1,j+13);Y15(j-1)=A(j+1,j+14);
    Y16(j-1)=A(j+1,j+15);Y17(j-1)=A(j+1,j+16);Y18(j-1)=A(j+1,j+17);Y19(j-1)=A(j+1,j+18);Y20(j-1)=A(j+1,j+19);
    Y21(j-1)=A(j+1,j+20);Y22(j-1)=A(j+1,j+21);Y23(j-1)=A(j+1,j+22);Y24(j-1)=A(j+1,j+23);
end

std_us_ur=nanstd([Y1' Y2' Y3' Y4' Y5' Y6' Y7' Y8' Y9' Y10' Y11' Y12' Y13' Y14' Y15' Y16' Y17' Y18' Y19' Y20' Y21' Y22' Y23' Y24']-Y24'*ones(1,24))./nanstd(A(:,end));

A=JP_UR;nn=size(A,2);

for j=2:nn-23
    Y1(j-1)=A(j+1,j);Y2(j-1)=A(j+1,j+1);Y3(j-1)=A(j+1,j+2);Y4(j-1)=A(j+1,j+3);Y5(j-1)=A(j+1,j+4);
    Y6(j-1)=A(j+1,j+5);Y7(j-1)=A(j+1,j+6);Y8(j-1)=A(j+1,j+7);Y9(j-1)=A(j+1,j+8);Y10(j-1)=A(j+1,j+9);
    Y11(j-1)=A(j+1,j+10);Y12(j-1)=A(j+1,j+11);Y13(j-1)=A(j+1,j+12);Y14(j-1)=A(j+1,j+13);Y15(j-1)=A(j+1,j+14);
    Y16(j-1)=A(j+1,j+15);Y17(j-1)=A(j+1,j+16);Y18(j-1)=A(j+1,j+17);Y19(j-1)=A(j+1,j+18);Y20(j-1)=A(j+1,j+19);
    Y21(j-1)=A(j+1,j+20);Y22(j-1)=A(j+1,j+21);Y23(j-1)=A(j+1,j+22);Y24(j-1)=A(j+1,j+23);
end

std_jp_ur=nanstd([Y1' Y2' Y3' Y4' Y5' Y6' Y7' Y8' Y9' Y10' Y11' Y12' Y13' Y14' Y15' Y16' Y17' Y18' Y19' Y20' Y21' Y22' Y23' Y24']-Y24'*ones(1,24))./nanstd(A(:,end));
std_jp_ur(1)=NaN;

figure(9)
plot(1:24,std_ea_ur,'b-d',1:24,std_us_ur,'r-s',1:24,std_jp_ur,'g-^'),title('Revisions for UR'),...
    xlabel('months after reference period'), ylabel('standard deviation of the revisions'),legend('EA','US','JP')
